import request from '@/api/request.js'

export const getMenuListApi = function (param) {
  return request({
    url: '/menus',
    method: 'get',
    params: param,
  })
}

export const getUserListApi = function (param) {
  return request({
    url: '/users',
    method: 'get',
    params: {
      query: param.query,
      pagenum: param.pagenum,
      pagesize: param.pagesize,
    },
  })
}

export const changeUserStateApi = function (param) {
  return request({
    url: `/users/${param.id}/state/${param.mg_state}`,
    method: 'put',
  })
}

export const addUserApi = function (params) {
  return request({
    url: '/users',
    method: 'post',
    data: {
      username: params.username,
      password: params.password,
      email: params.email,
      mobile: params.mobile,
    },
  })
}

export const editUserInfoApi = function (param) {
  return request({
    url: `/users/${param.id}`,
    method: 'put',
    data: {
      id: param.id,
      email: param.email,
      mobile: param.mobile,
    },
  })
}

export const deleteUserApi = function (param) {
  return request({
    url: `/users/${param}`,
    method: 'delete',
  })
}
